home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / compat / strerror.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-18  |  11.0 KB  |  471 lines

  1. /* 
  2.  * strerror.c --
  3.  *
  4.  *    Source code for the "strerror" library routine.
  5.  *
  6.  * Copyright (c) 1991-1993 The Regents of the University of California.
  7.  * Copyright (c) 1994 Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  */
  12.  
  13. #ifndef lint
  14. static char sccsid[] = "@(#) strerror.c 1.10 94/12/17 16:26:21";
  15. #endif /* not lint */
  16.  
  17. #include "tclInt.h"
  18. #include "tclPort.h"
  19.  
  20. extern int sys_nerr;
  21. extern char *sys_errlist[];
  22. /*
  23.  *----------------------------------------------------------------------
  24.  *
  25.  * strerror --
  26.  *
  27.  *    Map an integer error number into a printable string.
  28.  *
  29.  * Results:
  30.  *    The return value is a pointer to a string describing
  31.  *    error.  The first character of string isn't capitalized.
  32.  *
  33.  * Side effects:
  34.  *    Each call to this procedure may overwrite the value returned
  35.  *    by the previous call.
  36.  *
  37.  *----------------------------------------------------------------------
  38.  */
  39.  
  40. char *
  41. strerror(error)
  42.     int error;            /* Integer identifying error (must be
  43.                  * one of the officially-defined Sprite
  44.                  * errors, as defined in errno.h). */
  45. {
  46.     static char msg[50];
  47.  
  48. #ifndef NO_SYS_ERRLIST
  49.     if ((error <= sys_nerr) && (error > 0)) {
  50.     return sys_errlist[error];
  51.     }
  52. #else
  53.     switch (error) {
  54. #ifdef E2BIG
  55.     case E2BIG: return "argument list too long";
  56. #endif
  57. #ifdef EACCES
  58.     case EACCES: return "permission denied";
  59. #endif
  60. #ifdef EADDRINUSE
  61.     case EADDRINUSE: return "address already in use";
  62. #endif
  63. #ifdef EADDRNOTAVAIL
  64.     case EADDRNOTAVAIL: return "can't assign requested address";
  65. #endif
  66. #ifdef EADV
  67.     case EADV: return "advertise error";
  68. #endif
  69. #ifdef EAFNOSUPPORT
  70.     case EAFNOSUPPORT: return "address family not supported by protocol family";
  71. #endif
  72. #ifdef EAGAIN
  73.     case EAGAIN: return "no more processes";
  74. #endif
  75. #ifdef EALIGN
  76.     case EALIGN: return "EALIGN";
  77. #endif
  78. #ifdef EALREADY
  79.     case EALREADY: return "operation already in progress";
  80. #endif
  81. #ifdef EBADE
  82.     case EBADE: return "bad exchange descriptor";
  83. #endif
  84. #ifdef EBADF
  85.     case EBADF: return "bad file number";
  86. #endif
  87. #ifdef EBADFD
  88.     case EBADFD: return "file descriptor in bad state";
  89. #endif
  90. #ifdef EBADMSG
  91.     case EBADMSG: return "not a data message";
  92. #endif
  93. #ifdef EBADR
  94.     case EBADR: return "bad request descriptor";
  95. #endif
  96. #ifdef EBADRPC
  97.     case EBADRPC: return "RPC structure is bad";
  98. #endif
  99. #ifdef EBADRQC
  100.     case EBADRQC: return "bad request code";
  101. #endif
  102. #ifdef EBADSLT
  103.     case EBADSLT: return "invalid slot";
  104. #endif
  105. #ifdef EBFONT
  106.     case EBFONT: return "bad font file format";
  107. #endif
  108. #ifdef EBUSY
  109.     case EBUSY: return "mount device busy";
  110. #endif
  111. #ifdef ECHILD
  112.     case ECHILD: return "no children";
  113. #endif
  114. #ifdef ECHRNG
  115.     case ECHRNG: return "channel number out of range";
  116. #endif
  117. #ifdef ECOMM
  118.     case ECOMM: return "communication error on send";
  119. #endif
  120. #ifdef ECONNABORTED
  121.     case ECONNABORTED: return "software caused connection abort";
  122. #endif
  123. #ifdef ECONNREFUSED
  124.     case ECONNREFUSED: return "connection refused";
  125. #endif
  126. #ifdef ECONNRESET
  127.     case ECONNRESET: return "connection reset by peer";
  128. #endif
  129. #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
  130.     case EDEADLK: return "resource deadlock avoided";
  131. #endif
  132. #ifdef EDEADLOCK
  133.     case EDEADLOCK: return "resource deadlock avoided";
  134. #endif
  135. #ifdef EDESTADDRREQ
  136.     case EDESTADDRREQ: return "destination address required";
  137. #endif
  138. #ifdef EDIRTY
  139.     case EDIRTY: return "mounting a dirty fs w/o force";
  140. #endif
  141. #ifdef EDOM
  142.     case EDOM: return "math argument out of range";
  143. #endif
  144. #ifdef EDOTDOT
  145.     case EDOTDOT: return "cross mount point";
  146. #endif
  147. #ifdef EDQUOT
  148.     case EDQUOT: return "disk quota exceeded";
  149. #endif
  150. #ifdef EDUPPKG
  151.     case EDUPPKG: return "duplicate package name";
  152. #endif
  153. #ifdef EEXIST
  154.     case EEXIST: return "file already exists";
  155. #endif
  156. #ifdef EFAULT
  157.     case EFAULT: return "bad address in system call argument";
  158. #endif
  159. #ifdef EFBIG
  160.     case EFBIG: return "file too large";
  161. #endif
  162. #ifdef EHOSTDOWN
  163.     case EHOSTDOWN: return "host is down";
  164. #endif
  165. #ifdef EHOSTUNREACH
  166.     case EHOSTUNREACH: return "host is unreachable";
  167. #endif
  168. #ifdef EIDRM
  169.     case EIDRM: return "identifier removed";
  170. #endif
  171. #ifdef EINIT
  172.     case EINIT: return "initialization error";
  173. #endif
  174. #ifdef EINPROGRESS
  175.     case EINPROGRESS: return "operation now in progress";
  176. #endif
  177. #ifdef EINTR
  178.     case EINTR: return "interrupted system call";
  179. #endif
  180. #ifdef EINVAL
  181.     case EINVAL: return "invalid argument";
  182. #endif
  183. #ifdef EIO
  184.     case EIO: return "I/O error";
  185. #endif
  186. #ifdef EISCONN
  187.     case EISCONN: return "socket is already connected";
  188. #endif
  189. #ifdef EISDIR
  190.     case EISDIR: return "illegal operation on a directory";
  191. #endif
  192. #ifdef EISNAME
  193.     case EISNAM: return "is a name file";
  194. #endif
  195. #ifdef ELBIN
  196.     case ELBIN: return "ELBIN";
  197. #endif
  198. #ifdef EL2HLT
  199.     case EL2HLT: return "level 2 halted";
  200. #endif
  201. #ifdef EL2NSYNC
  202.     case EL2NSYNC: return "level 2 not synchronized";
  203. #endif
  204. #ifdef EL3HLT
  205.     case EL3HLT: return "level 3 halted";
  206. #endif
  207. #ifdef EL3RST
  208.     case EL3RST: return "level 3 reset";
  209. #endif
  210. #ifdef ELIBACC
  211.     case ELIBACC: return "can not access a needed shared library";
  212. #endif
  213. #ifdef ELIBBAD
  214.     case ELIBBAD: return "accessing a corrupted shared library";
  215. #endif
  216. #ifdef ELIBEXEC
  217.     case ELIBEXEC: return "can not exec a shared library directly";
  218. #endif
  219. #ifdef ELIBMAX
  220.     case ELIBMAX: return
  221.         "attempting to link in more shared libraries than system limit";
  222. #endif
  223. #ifdef ELIBSCN
  224.     case ELIBSCN: return ".lib section in a.out corrupted";
  225. #endif
  226. #ifdef ELNRNG
  227.     case ELNRNG: return "link number out of range";
  228. #endif
  229. #ifdef ELOOP
  230.     case ELOOP: return "too many levels of symbolic links";
  231. #endif
  232. #ifdef EMFILE
  233.     case EMFILE: return "too many open files";
  234. #endif
  235. #ifdef EMLINK
  236.     case EMLINK: return "too many links";
  237. #endif
  238. #ifdef EMSGSIZE
  239.     case EMSGSIZE: return "message too long";
  240. #endif
  241. #ifdef EMULTIHOP
  242.     case EMULTIHOP: return "multihop attempted";
  243. #endif
  244. #ifdef ENAMETOOLONG
  245.     case ENAMETOOLONG: return "file name too long";
  246. #endif
  247. #ifdef ENAVAIL
  248.     case ENAVAIL: return "not available";
  249. #endif
  250. #ifdef ENET
  251.     case ENET: return "ENET";
  252. #endif
  253. #ifdef ENETDOWN
  254.     case ENETDOWN: return "network is down";
  255. #endif
  256. #ifdef ENETRESET
  257.     case ENETRESET: return "network dropped connection on reset";
  258. #endif
  259. #ifdef ENETUNREACH
  260.     case ENETUNREACH: return "network is unreachable";
  261. #endif
  262. #ifdef ENFILE
  263.     case ENFILE: return "file table overflow";
  264. #endif
  265. #ifdef ENOANO
  266.     case ENOANO: return "anode table overflow";
  267. #endif
  268. #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
  269.     case ENOBUFS: return "no buffer space available";
  270. #endif
  271. #ifdef ENOCSI
  272.     case ENOCSI: return "no CSI structure available";
  273. #endif
  274. #ifdef ENODATA
  275.     case ENODATA: return "no data available";
  276. #endif
  277. #ifdef ENODEV
  278.     case ENODEV: return "no such device";
  279. #endif
  280. #ifdef ENOENT
  281.     case ENOENT: return "no such file or directory";
  282. #endif
  283. #ifdef ENOEXEC
  284.     case ENOEXEC: return "exec format error";
  285. #endif
  286. #ifdef ENOLCK
  287.     case ENOLCK: return "no locks available";
  288. #endif
  289. #ifdef ENOLINK
  290.     case ENOLINK: return "link has be severed";
  291. #endif
  292. #ifdef ENOMEM
  293.     case ENOMEM: return "not enough memory";
  294. #endif
  295. #ifdef ENOMSG
  296.     case ENOMSG: return "no message of desired type";
  297. #endif
  298. #ifdef ENONET
  299.     case ENONET: return "machine is not on the network";
  300. #endif
  301. #ifdef ENOPKG
  302.     case ENOPKG: return "package not installed";
  303. #endif
  304. #ifdef ENOPROTOOPT
  305.     case ENOPROTOOPT: return "bad proocol option";
  306. #endif
  307. #ifdef ENOSPC
  308.     case ENOSPC: return "no space left on device";
  309. #endif
  310. #ifdef ENOSR
  311.     case ENOSR: return "out of stream resources";
  312. #endif
  313. #ifdef ENOSTR
  314.     case ENOSTR: return "not a stream device";
  315. #endif
  316. #ifdef ENOSYM
  317.     case ENOSYM: return "unresolved symbol name";
  318. #endif
  319. #ifdef ENOSYS
  320.     case ENOSYS: return "function not implemented";
  321. #endif
  322. #ifdef ENOTBLK
  323.     case ENOTBLK: return "block device required";
  324. #endif
  325. #ifdef ENOTCONN
  326.     case ENOTCONN: return "socket is not connected";
  327. #endif
  328. #ifdef ENOTDIR
  329.     case ENOTDIR: return "not a directory";
  330. #endif
  331. #ifdef ENOTEMPTY
  332.     case ENOTEMPTY: return "directory not empty";
  333. #endif
  334. #ifdef ENOTNAM
  335.     case ENOTNAM: return "not a name file";
  336. #endif
  337. #ifdef ENOTSOCK
  338.     case ENOTSOCK: return "socket operation on non-socket";
  339. #endif
  340. #ifdef ENOTTY
  341.     case ENOTTY: return "inappropriate device for ioctl";
  342. #endif
  343. #ifdef ENOTUNIQ
  344.     case ENOTUNIQ: return "name not unique on network";
  345. #endif
  346. #ifdef ENXIO
  347.     case ENXIO: return "no such device or address";
  348. #endif
  349. #ifdef EOPNOTSUPP
  350.     case EOPNOTSUPP: return "operation not supported on socket";
  351. #endif
  352. #ifdef EPERM
  353.     case EPERM: return "not owner";
  354. #endif
  355. #ifdef EPFNOSUPPORT
  356.     case EPFNOSUPPORT: return "protocol family not supported";
  357. #endif
  358. #ifdef EPIPE
  359.     case EPIPE: return "broken pipe";
  360. #endif
  361. #ifdef EPROCLIM
  362.     case EPROCLIM: return "too many processes";
  363. #endif
  364. #ifdef EPROCUNAVAIL
  365.     case EPROCUNAVAIL: return "bad procedure for program";
  366. #endif
  367. #ifdef EPROGMISMATCH
  368.     case EPROGMISMATCH: return "program version wrong";
  369. #endif
  370. #ifdef EPROGUNAVAIL
  371.     case EPROGUNAVAIL: return "RPC program not available";
  372. #endif
  373. #ifdef EPROTO
  374.     case EPROTO: return "protocol error";
  375. #endif
  376. #ifdef EPROTONOSUPPORT
  377.     case EPROTONOSUPPORT: return "protocol not suppored";
  378. #endif
  379. #ifdef EPROTOTYPE
  380.     case EPROTOTYPE: return "protocol wrong type for socket";
  381. #endif
  382. #ifdef ERANGE
  383.     case ERANGE: return "math result unrepresentable";
  384. #endif
  385. #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
  386.     case EREFUSED: return "EREFUSED";
  387. #endif
  388. #ifdef EREMCHG
  389.     case EREMCHG: return "remote address changed";
  390. #endif
  391. #ifdef EREMDEV
  392.     case EREMDEV: return "remote device";
  393. #endif
  394. #ifdef EREMOTE
  395.     case EREMOTE: return "pathname hit remote file system";
  396. #endif
  397. #ifdef EREMOTEIO
  398.     case EREMOTEIO: return "remote i/o error";
  399. #endif
  400. #ifdef EREMOTERELEASE
  401.     case EREMOTERELEASE: return "EREMOTERELEASE";
  402. #endif
  403. #ifdef EROFS
  404.     case EROFS: return "read-only file system";
  405. #endif
  406. #ifdef ERPCMISMATCH
  407.     case ERPCMISMATCH: return "RPC version is wrong";
  408. #endif
  409. #ifdef ERREMOTE
  410.     case ERREMOTE: return "object is remote";
  411. #endif
  412. #ifdef ESHUTDOWN
  413.     case ESHUTDOWN: return "can't send afer socket shutdown";
  414. #endif
  415. #ifdef ESOCKTNOSUPPORT
  416.     case ESOCKTNOSUPPORT: return "socket type not supported";
  417. #endif
  418. #ifdef ESPIPE
  419.     case ESPIPE: return "invalid seek";
  420. #endif
  421. #ifdef ESRCH
  422.     case ESRCH: return "no such process";
  423. #endif
  424. #ifdef ESRMNT
  425.     case ESRMNT: return "srmount error";
  426. #endif
  427. #ifdef ESTALE
  428.     case ESTALE: return "stale remote file handle";
  429. #endif
  430. #ifdef ESUCCESS
  431.     case ESUCCESS: return "Error 0";
  432. #endif
  433. #ifdef ETIME
  434.     case ETIME: return "timer expired";
  435. #endif
  436. #ifdef ETIMEDOUT
  437.     case ETIMEDOUT: return "connection timed out";
  438. #endif
  439. #ifdef ETOOMANYREFS
  440.     case ETOOMANYREFS: return "too many references: can't splice";
  441. #endif
  442. #ifdef ETXTBSY
  443.     case ETXTBSY: return "text file or pseudo-device busy";
  444. #endif
  445. #ifdef EUCLEAN
  446.     case EUCLEAN: return "structure needs cleaning";
  447. #endif
  448. #ifdef EUNATCH
  449.     case EUNATCH: return "protocol driver not attached";
  450. #endif
  451. #ifdef EUSERS
  452.     case EUSERS: return "too many users";
  453. #endif
  454. #ifdef EVERSION
  455.     case EVERSION: return "version mismatch";
  456. #endif
  457. #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
  458.     case EWOULDBLOCK: return "operation would block";
  459. #endif
  460. #ifdef EXDEV
  461.     case EXDEV: return "cross-domain link";
  462. #endif
  463. #ifdef EXFULL
  464.     case EXFULL: return "message tables full";
  465. #endif
  466.     }
  467. #endif /* ! NO_SYS_ERRLIST */
  468.     sprintf(msg, "unknown error (%d)", error);
  469.     return msg;
  470. }
  471.